<template>
   <div>
      <el-table :data="data" style="width: 100%">
         <el-table-column v-for="(item, index) in columns" :fixed="item.fixed" :width="item.width" :key="index"
            :prop="item.key" :label="item.title" width="180">
            <template slot-scope="scope">{{ item.render ? item.render(scope.row[item.key]) : scope.row[item.key] }}
                    </template>
         </el-table-column>
      </el-table>
   </div>
</template>
<script>
import { getAnalysis } from '@/api/analysis.js';

export default {
   name: '',
   components: {

   },
   mixins: [],
   props: {

   },
   data() {
      return {
         columns: [
            {
               title: '名称', width: 60, key: 'dataType',
               fixed: 'left',
            },
            {
               title: '当月回报',
               width: 60,
               key: 'name',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '年底至今回报', width: 60, key: 'yearToDateReturn',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '2021年回报', width: 60, key: 'twentyOneReturn',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '2020年回报', width: 60, key: 'twentyReturn',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '年化回报', width: 60, key: 'annualizedReturn',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '年化标准差', width: 60, key: 'annualizedStandardDeviation',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '单月最大涨幅', width: 60, key: 'biggestDropMonth',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '单月最大跌幅', width: 60, key: 'biggestGainMonth',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '正回报月份占比', width: 60, key: 'percentagePositiveReturnMonths',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
            {
               title: '夏普比率', width: 60, key: 'sharpRatio',
               render: (val) => {
                  return ((val || 0)).toFixed(2)
               }
            },
            {
               title: '相关性', width: 60, key: 'correlation',
               render: (val) => {
                  return ((val || 0) ).toFixed(2)
               }
            },
            {
               title: '最大回撤', width: 60, key: 'maximumPullback',
               render: (val) => {
                  return ((val || 0) * 100).toFixed(2) + '%'
               }
            },
         ],
         data: [],
      }
   },
   computed: {

   },
   watch: {

   },
   mounted() {
      const companyId = this.$route.query.companyId;
      const fundId = this.$route.query.id
      getAnalysis({
         companyId,
         fundId,
      }).then(res => {
         this.data = res.data.dataAnalysisResult;
      })

   },
   methods: {

   }
};
</script>
<style lang='' scoped>
</style>